let arr = [1, 2, 4, 3, 3, 3, 42, 2, 2, 8]
function bubbleSort (arr) {
  let temp;
  for (let i = 0; i < arr.length - 1; i++) {
    for (let j = 0; j < arr.length - 1 - i; j++) {
      if (arr[j + 1] < arr[j]) {
        temp = arr[j]
        arr[j] = arr[j + 1]
        arr[j + 1] = temp
      }

    }
  }
  return arr
}//小到大

console.log('bubbleSort(arr)', bubbleSort(arr));
